package com.example.demo.controller;

import com.example.demo.model.service.MarkService;
import com.example.demo.model.service.OperateRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;

@Controller
public class OneUserMarks {
    private final static String OneUsersMarksPage = "OneUserMark";
    private final static String OneUsersMarksUrl = "/admin/OneUsersMarks";
    @Autowired
    private MarkService markService;
    @Autowired
    private OperateRecordService operateRecordService;
    @GetMapping(OneUsersMarksUrl+"/{id}")
    public String getOneUsersMarksPage(HttpServletRequest request, @PathVariable String id)
    {
        request.setAttribute("mark",markService.retrieveMarkById(id));
        request.setAttribute("records",operateRecordService.getOperateRecordById(id));
        return OneUsersMarksPage;
    }
    @GetMapping(OneUsersMarksUrl+"/{id}"+"/{message}")
    public String getOneUsersMarksPageMessage(HttpServletRequest request, @PathVariable String id,@PathVariable String message)
    {
        request.setAttribute("mark",markService.retrieveMarkById(id));
        request.setAttribute("records",operateRecordService.getOperateRecordById(id));
        request.setAttribute("message",message);
        return OneUsersMarksPage;
    }
}
